 <html>
 <!-- 1.如果路径已被引用则，不允许被修改？INSERT INTO wl_path values('2','2','2','2','2','2','2'); -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>SplitContainer Demo</title>
     <style type="text/css">
            @import "../dojo/dojo-release-1.0.0/dijit/themes/tundra/tundra.css";
            @import "../dojo/dojo-release-1.0.0/dojo/resources/dojo.css";
            @import "../dojo/dojo-release-1.0.0/dojox/grid/_grid/tundraGrid.css";
            @import "../dojo/dojo-release-1.0.0/dojox/grid/_grid/Grid.css";
            @import "../dojo/dojo-release-1.0.0/dojox/grid/_grid/Grid.css";
    		@import "../js/wlProject.css";
			
        </style>
        <script type="text/javascript" src="../dojo/dojo-release-1.0.0/dojo/dojo.js"
                djConfig="parseOnLoad: true, isDebug: true,locale: 'zh-cn', extraLocale: ['zh-TW', 'fr']"></script>
 <script>
    
            dojo.require("dojo.data.ItemFileWriteStore");
            dojo.require("dijit.layout.SplitContainer");
            dojo.require("dijit.layout.ContentPane");
            dojo.require("dijit.Tree");
            dojo.require("dojo.parser");
            dojo.require("dijit._tree.dndSource");
            dojo.require("dijit.layout.TabContainer");
            dojo.require("dijit.form.Button");
            dojo.require("dojox.grid.Grid");
            dojo.require("dojox.grid._data.model");
            dojo.require("dojo.i18n");
            dojo.require("dojox.validate._base");
            dojo.require("dijit.form.ValidationTextBox");
            dojo.require("dijit.form.TextBox");
            dojo.require("dijit.form.FilteringSelect");
            dojo.require("dojox.grid._data.dijitEditors");
            </script>
        
<script type="text/javascript" src="../js/soapclient.js">
        </script>
<script type="text/javascript" src="../js/wlProject.js">
        </script>
<script type="text/javascript" >


        
         var areadata =new Array();
         var placedata =  new Array();
         var querydata = new Array();
         
          var data =new Array();
         var poptarts ={ label:'name',identifier:'eId',items:data};
         var popStore = new dojo.data.ItemFileWriteStore({data: poptarts});
         
         
         var citySelectArray = new Array();
         var cityidSelectArray = new Array();
         var cityidSelectData = new Array();
         
         
         
         
          //按钮  
          var deletedata =new Array();
          //var itemt="区域";
          var identity=0;
          var selectNode;
          
           //验证方法要放在layout前面
           var formatNotNull = function(inDatum,inRowIndex){
               return dojox.validate.isText(inDatum, {minlength: 1}) ? inDatum : "<p style={color:red}> can not is null ! </p>";
      		 }
                        
           var transplaceID = function(inDatum,inRowIndex){
                 return dojox.validate.isText(inDatum, {minlength: 1}) ? citySelectArray[inDatum] : "<p style={color:red}> can not is null ! </p>";
                  }                
          
          
          model = new dojox.grid.data.Table(null, placedata);
          var layout =[{type: 'dojox.GridRowView', width: '20px' },{
                       
             rows: [
                      [
                       { name: '选择', width: 3, styles: 'text-align: center;', editor: dojox.grid.editors.Bool },
                       //{ name: 'no', width: 2, get: function(inRowIndex){ return inRowIndex+1;} },
                        {name: '名称', field: 2,width: 20,editor: dojox.grid.editors.Input ,formatter: formatNotNull},
                        {name: '路线起点', field: 3,width: 15, editor: dojox.grid.editors.Select,options:citySelectArray,values:cityidSelectArray,returnIndex:true,formatter:transplaceID},
                        {name: '路线终点', field: 4,width: 15, editor: dojox.grid.editors.Select,options:citySelectArray,values:cityidSelectArray,returnIndex:true,formatter:transplaceID},
                        {name: '距离', field: 5,width: 10, editor: dojox.grid.editors.Input ,formatter: formatNotNull},
                        {name: '时间', field: 6,width: 10, editor: dojox.grid.editors.Input ,formatter: formatNotNull}
                       ]
                     ]
                                                                    }];
//保存列表
                   
          addRow = function(){
          	endgrid.addRow([false,0,"","","","","","",""],endgrid.model.getRowCount());
	         	endgrid.updateRow();
	         } 
	         
          function call_funUpd() {
           var s = endgrid.selection.getSelected();
            var url = getUrl()+ "services/BasicManageService";
           
           for(var i=0;i<s.length;i++){
           var ii=s[i];
           
            var thisCell=endgrid.model.data[ii];
         
             var padd = new SOAPClientParameters2();
            
             var pathvo=new Object();
             pathvo.id=thisCell[1];
             if(dojox.validate.isText(thisCell[2], {minlength: 1})){
              pathvo.pathName=thisCell[2];
             }else{
             continue;
             }
              if(dojox.validate.isText(thisCell[4], {minlength: 1})){
              alert(citySelectArray[thisCell[4]]);
             pathvo.endPlaceID=cityidSelectArray[thisCell[4]];
             pathvo.endPlace=citySelectArray[thisCell[4]];
             }else{
             continue;
             }
             if(dojox.validate.isText(thisCell[3], {minlength: 1})){
             pathvo.startPlaceID=cityidSelectArray[thisCell[3]];
             pathvo.startPlace=citySelectArray[thisCell[3]];
             }else{
               continue;
               }
              if(dojox.validate.isText(thisCell[5], {minlength: 1})){
             pathvo.distance=thisCell[5]; 
             }else{
             continue;
             }
            // if(dojox.validate.isText(thisCell[1], {minlength: 1})){
            // pathvo.loanStandard='1';
            /* }else{
             continue;
             }*/
              if(dojox.validate.isText(thisCell[6], {minlength: 1})){
             pathvo.time=thisCell[6];}else{
             continue;
             }
            
          if(thisCell[1]==0){//新增的记录
                  
                padd.add('WlPathVO',pathvo);
                SOAPClient.invoke(url, "createPath", padd, false,  function GetEnu_callBack(ul, soapResponse){
                endgrid.model.setDatum(ul,i,1);
                });
          }else{//修改的记录
                             
                padd.add('WlPathVO',pathvo);
                SOAPClient.invoke(url, "updatePath", padd, false,  function GetEnu_callBack(ul, soapResponse){
                
                });
             }
		       //
          }
          
          //提交删除的记录？
              for(var i=0;i<deletedata.length;i++){
                   var pdel = new SOAPClientParameters();      
                   pdel.add('ids',deletedata[i]);
                 SOAPClient.invoke(url, "deletePath", pdel, false,  function GetEnu_callBack(ul, soapResponse){
                 
                });
              }
              endgrid.updateRow();
              deletedata=new Array();
              
              
           }
          
          
          function removeSelectedRows(){
           var s = endgrid.selection.getSelected();
           for(var i=0;i<s.length;i++){ 
             var ii=s[i];
             var thisCell=endgrid.model.data[ii];
             if(thisCell[1]!=0){//要删除的记录
               deletedata.splice(deletedata.length,0,thisCell[1]);
             }
           }    
           endgrid.removeSelectedRows();
           endgrid.updateRow();
          
          }   
     
        
          
        
           
         function init(){
         
           dojo.connect(endgrid, "doStartEdit", function(inCell, inRowIndex){
           
            });  
            
            //单击查询列表里的记录，可选中树中的相应节点
	       dojo.connect(endgrid, "onRowClick", function(e){
	               
	        });  
        
                                 
         
         
             //添加区域结点
                
                var url = getUrl()+ "services/BasicManageService";
                var pl = new SOAPClientParameters();
                //pl.add('eType','区域') ;
                pl.add('type','区域') ;
                SOAPClient.invoke(url, "getPlacevoByPlaceType", pl, false,  function GetEnu_callBack(ul, soapResponse){
                  var pInfo = {
                        					parent: null,		
                        					attribute: "children"	
                        				};
                    for(var i = 0; i < ul.length; i++){		
                                 var ulo=ul[i];
                                 popStore.newItem({name: ulo["ns:placeName"],type:ulo["ns:placeType"] ,eId:ulo["ns:id"]}, pInfo);
                                /* var items = new Array();
                                  items[0] = false;
                                  items[1] = ulo["ns:placeName"];
                                  items[2] = ulo["ns:postCode"];
                                  items[3] = ulo["ns:remark"];
                                  items[5] = ulo["ns:id"];
                                  items[4] = ulo["ns:placeType"];
                                  placedata[i]=items;*/
                            }
                    
               });
                       
                      
            //添加省份、城市结点;同时初始化地点下拉列表的数组
                        var chitem;
            var chdata =new Array();
            var _tree=dijit.byId("tree");
            var childrenArray1=_tree.getChildren();
            cityidSelectData.splice(citySelectArray.length,0,{name:'',label:'',id:0});
            for (var i=0; i<childrenArray1.length; i++){//begin	
                var p2 = new SOAPClientParameters();
                var chNode =childrenArray1[i];
                chitem=chNode.item;
                var p2Info = {	parent: chitem,		
			                    attribute: "children"	
			                 };
			    
                p2.add('parentPlaceId',chitem.eId) ;
                SOAPClient.invoke(url, "getPlacevoByParentPlaceId", p2 ,false,  function GetEnu_callBack(ul1, soapResponse){  
                    
                    for(var ii = 0; ii < ul1.length; ii++){	   
                                      var ulo=ul1[ii];
                                     var newItemCity=	popStore.newItem({name: ulo["ns:placeName"],type:ulo["ns:placeType"] ,eId:ulo["ns:id"]}, p2Info);
                                     	//------
                                                   
                                                     var p3 = new SOAPClientParameters();
                                                     var p3Info = {
                                                                    parent: newItemCity,		
                                                                    attribute: "children"	
                                                                   };
                                                    p3.add('parentPlaceId',ulo["ns:id"]) ;
                                                    SOAPClient.invoke(url, "getPlacevoByParentPlaceId", p3 ,false,  function GetEnu_callBack(ul2, soapResponse){  
                                                    for(var j = 0; j < ul2.length; j++){
                                                            var uloo=ul2[j];		
                                                            popStore.newItem( {name: uloo["ns:placeName"],type:uloo["ns:placeType"] ,eId:uloo["ns:id"]}, p3Info);
                                                    citySelectArray.splice(citySelectArray.length,0,uloo["ns:placeName"]);
                                                    cityidSelectArray.splice(cityidSelectArray.length,0,uloo["ns:id"]);
                                                    cityidSelectData.splice(cityidSelectData.length,0,{name:uloo["ns:placeName"],label:uloo["ns:placeName"],id:uloo["ns:id"]});
                                                     }});
                                                    
                                     	//----------
                        }
                   });
                 _tree._expandNode(chNode);
               
                }//end
                var placeStoreData={ label:'name',identifier:'id',items:cityidSelectData};
                var placeStore = new dojo.data.ItemFileReadStore({data: placeStoreData});
                queryend.store=placeStore;
                queryend.setValue('0');
                queryend.setDisplayedValue('');
                querystart.store=placeStore;
                querystart.setValue('0');
                querystart.setDisplayedValue('');
                
                
         //初始化列表----begin
         
         //初始化列表----end
            
            
            
           //查询列表----begin
             dojo.connect(_tree, "onClick", function(item,node){
                    placedata = new Array();
                    selectNode=node;
                    identity = _tree.store.getIdentity(item);
                    var url0 =getUrl()+ "services/BasicManageService";
                    var p0 = new SOAPClientParameters();
                    p0.add('endPlaceID',item["eId"]) ;
                    SOAPClient.invoke(url0, "getPathvoByEndPlace", p0, false,  function GetEnu_callBack(ul, soapResponse){   
                   
                     for(var i = 0; i < ul.length; i++){		
                      var items = new Array();
                      var ulo=ul[i];
                        items[0] = false;
                        items[1] = ulo["ns:id"];
                        items[2] = ulo["ns:pathName"];
                        items[3] = ulo["ns:startPlace"];
                        items[4] = ulo["ns:endplace"];
                        items[5] = ulo["ns:distance"];
                        items[6] = ulo["ns:time"];
                        placedata[i]=items;
                    }                
                });       
                model.setData(placedata);
                endgrid.selection.clear();
                
                
                
                var titles=node.item["name"];
                var parentNodes=node;
              
                while(parentNodes.getParent()!= null&& parentNodes.getParent()["id"]!="tree"){
                      parentNodes=parentNodes.getParent();
                      titles=parentNodes.item["name"]+' '+titles;
                };
              //	dojo.byId("placetitle").innerHTML = titles +"";
                deletedata =new Array();                       
                                     
                                     });  
              
            	
            
            
            
            
           //查询列表----end
           dojo.connect(endgrid.model, "onSelected", function(e){
                    //alert("c3="+e);
                  
            });  
          
        
           }//END INIT
            
           dojo.addOnLoad(init);
           

          //查询按钮
          
          
          function querybutton(){
          //根据终点树查询的范围内进行查询
              var url =getUrl()+  "services/BasicManageService";
              var p = new SOAPClientParameters();
             // alert(queryname.getDisplayedValue()+querypostcode.getDisplayedValue()+querytype.getDisplayedValue()+queryremark.getDisplayedValue());
              p.add('pathName','%'+queryname.getDisplayedValue()+'%') ;
              p.add('distance',querydistance.getDisplayedValue()) ;
              p.add('loanStandard',querytype.getDisplayedValue()) ;
              p.add('time',querytime.getDisplayedValue()) ;
              p.add('startPlaceId',querystart.getValue()); 
              p.add('endPlaceId',queryend.getValue()) ; 
              p.add('startPlace','%'+querystart.getDisplayedValue()+'%') ; 
              p.add('endPlace','%'+queryend.getDisplayedValue()+'%') ; 
              /*p.add('startPlaceId','1'); 
              p.add('endPlaceId','1') ; 
              p.add('startPlace','%11%') ; 
              p.add('endPlace','%22%') ; */
               
              
             // alert(queryend.getValue()+queryend.getDisplayedValue());   
                SOAPClient.invoke(url, "getPathVO", p, false,  function GetEnu_callBack(ul, soapResponse){   
                     querydata=new Array();        
                     for(var i = 0; i < ul.length; i++){		
                      var items = new Array();
                      var ulo=ul[i];
                        items[0] = false;
                        items[1] = ulo["ns:id"];
                        items[2] = ulo["ns:pathName"];
                        items[3] = ulo["ns:startPlaceID"];
                        items[4] = ulo["ns:endplaceID"];
                        items[5] = ulo["ns:distance"];
                        items[6] = ulo["ns:time"];
                      querydata[i]=items;
                    }                
                });       
                model.setData(querydata); 
         }
           
          function  autoaddbutton(){
          
          
          }
           
           
           
             
</script>
</head>
<body class="tundra">
       
	
	 <div dojoType="dijit.layout.SplitContainer"   orientation="horizontal"  sizerWidth="7" activeSizing="true" class ="split1" id="split1" 	style="border: 1px solid #bfbfbf;width: 1250px; height: 800px; align:center "  >
		
         <div dojoType="dijit.layout.ContentPane" id="treePane"  sizeMin="20" sizeShare="20"   >
                     
                <div id="tree"  class="container" dojoType="dijit.Tree" persist="false" store="popStore" labelAttr="name"  childrenAttr="children"  ></div> 
         </div>
                
        <div dojoType="dijit.layout.ContentPane" sizeMin="50" sizeShare="50"  >
              <a onclick="querydisplay();"><img src="../image/332.gif" height="20" width="20" border="0">查询</a>
              <div id="queryDiv" style="margin-right: 30px; width:100%; height: 23%; display:none;" >
        
                       
     
                        <table align="center" width=86% class="queryTable"  >
                        <tr height="3" ></tr>
					          <tr align="center"><td >请输入查询条件：</td><td></td></tr> <tr height="6" ></tr>
					          <tr align="center" >
					               <td>名称：<input type="text" jsId="queryname"   dojoType="dijit.form.TextBox"  /></td>
					               <td>距离：<input type="text" jsId="querydistance" value="0"  dojoType="dijit.form.TextBox"  /></td>
					          </tr><tr height="6" ></tr>
					          <tr align="center" >
                                   <td>时间：<input type="text" jsId="querytime"  value="0"  dojoType="dijit.form.TextBox"  /></td>
                                   <td>类型：<input type="text" jsId="querytype"  value="1"  dojoType="dijit.form.TextBox"  /></td>
                    </tr><tr height="6" ></tr>
                             <!--  所有城市名称的下拉列表，如果输入城市名称需自动匹配ID，新城市需要提问后自动增加store="placeStore"-->
					          <tr align="center" >
						          <td>路线起点：<select dojoType="dijit.form.FilteringSelect"  jsId="querystart"   autocomplete="true"/></td>
						          <td>路线终点：<select dojoType="dijit.form.FilteringSelect"  jsId="queryend"    autocomplete="false" /></td>
						      </tr><tr height="3" ></tr><tr align="center"><td></td><td ><a onclick="querybutton();"><img src="../image/332.gif" height="20" width="20" border="0">确 定</a></td></tr> <tr height="6" ></tr>
					    </table>
          
        
      </div>
      
      <div align="right">
        <a onclick="addRow();"><img src="../image/371.gif" height="20" width="20" border="0">新 增</a>
        <a onclick="addRow();"><img src="../image/3910.jpg" height="20" width="20" border="0">增加类似</a>
        <a onclick="addRow();"><img src="../image/334.gif" height="20" width="20" border="0">增加返程</a>
        <a onclick="removeSelectedRows();"><img src="../image/808.gif" height="20" width="20" border="0">删 除</a>
        <a onclick="call_funUpd();"><img src="../image/334.gif" height="20" width="20" border="0">保 存</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
      </div>   
        
         <div  style="{ width:100%; height: 1%; }" > </div>
        <div id="endgrid"  dojoType="dojox.Grid"  autoWidth="false" style="{width:100%;height:85%}" 	jsId="endgrid"	model="model" structure="Layout" singleClickEdit="true"  ></div>
        
        <!--div align="center">
         <button dojoType="dijit.form.Button" onclick="addRow()"> 新 增 </button>&nbsp;&nbsp;&nbsp;                                   
         <button dojoType="dijit.form.Button" onclick="addRow()"> 增加类似 </button>&nbsp;&nbsp;&nbsp; 
         <button dojoType="dijit.form.Button" onclick="addRow()"> 增加返程                  </button>&nbsp;&nbsp;&nbsp;                                                                     
         <button dojoType="dijit.form.Button" onclick="removeSelectedRows()">删 除</button>  
         <button dojoType="dijit.form.Button" onclick="call_funUpd()">保 存</button>&nbsp;&nbsp;&nbsp;
        </div-->   
      
      
      


</div></div>
</body></html>
